<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php  $data['leftnav']=2;$this->load->view('admin/header.html',$data)?>

<script type="text/javascript">
    function Success(data) {
        $.Success(data);
    }
    function EditUse(mid, state) {
        $.post('/admin/menu/setuse', { 'mid': mid, 'state': state }, function (data) {
            var jsonData = $.parseJSON(data);

            if (jsonData.Statu == 'ok') {
                alert(jsonData.Msg);
                location.href = jsonData.BackUrl;
            }
            else {
                alert(jsonData.Msg);
            }
        });
    }

    function Del(mid, mchid) {
        if (mchid > 0) {
            if (!confirm('该栏目有子集栏目，如果要删除该栏目，其子集栏目有都相应删除，确定删除该栏目？')) {
                return;
            }
        }
        $.post('/admin/menu/delmenu'+"?returnurl=<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>", { 'mid': mid }, function (data) {
            var jsonData = $.parseJSON(data);
            if (jsonData.Statu == 'ok') {
                Success(jsonData)
            }
            else {
                Success(jsonData)
            }
        });

    }
</script>
<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">
        DouPHP 管理中心
        <b>></b>
        <strong>栏目列表</strong>
    </div>
    <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3>
            <a href="<?php echo site_url('admin/menu/addmenu')?>" class="actionBtn">添加栏目</a>栏目列表
        </h3>
        <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
            <tr>
                <th width="30" align="center">编号</th>
                <th align="left">栏目名称</th>
                <th align="center">是否启用</th>
                <th align="center">操作</th>
            </tr>
            <?php foreach($menuList as $menuItem):?>
            <tr <?php if($menuItem->misuse<1){echo('style="background-color:#c0c0c0;" title="栏目停用"');}?>>

                <td align="center"><?php echo $menuItem->mid;?></td>
                <td><?php if($menuItem->mlevel>1){for($i=0;$i<$menuItem->mlevel;$i++){echo('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');}echo('|-');}?><?php echo $menuItem->mtitle;?></td>
                <td align="center"><a href="javascript:EditUse(<?php echo $menuItem->mid?>,<?php echo $menuItem->misuse?>)"><?php echo $menuItem->misuse<1?"启用":"停用" ?></a></td>
                <td align="center">
                    <a href="<?php echo site_url('admin/menu/editmenu/'.$menuItem->mid)?>">编辑</a>|
                    <a href="javascript:Del(<?php echo $menuItem->mid?>,<?php echo $menuItem->mchild?>)">删除</a>
                </td>
            </tr>
            <?php endforeach; ?>
        </table>
        <div class='page'>
            <!--<?php echo $links?>-->
        </div>
    </div>
</div>